import os

#获取被计算的目录信息
totalsize=0
def files(dir):
    global totalsize
    dlist=os.listdir(dir)
   
    for ff in dlist:
            files1=os.path.join(dir,ff)
          
            if os.path.isfile(files1):
                    totalsize+=os.path.getsize(files1)
                   
            if os.path.isdir(files1):
                    files(files1)

paths='./Practice'
files(paths)
print("目标路径总大小为：",totalsize)
